Test automation method for software programs

ABSTRACT

A method for testing a software program creates test data by simulating data exchange messages between a server and a client and stores test data in Comma Separated Value (CSV) files. Data repository files stored in the CSV format can be edited by common tools, like a spreadsheet program, and can be maintained easily. The test automation method provides a data capturer tool so that the data repository could be created based on any existing test environment. The test automation method converts data repository files and simulates messages in order to load data to a mobile infrastructure system and set up data fixtures. The test automation method could be integrated in a build process so that data repository and test cases are validated against any program changes periodically.

BACKGROUND

Proper test automation can improve software quality and efficiency of software development. A test program usually includes many test cases, which are tested on some test fixtures. A test fixture is a determined running background of a known set of objects and states.

One difficulty found for test automation for a mobile infrastructure based solution is to set up test fixtures. A mobile infrastructure based solution usually contains three parts: the server side, the client side, and the middle part which includes mobile infrastructure middleware and client framework for exchanging data between the server and the client.

One approach to solving this problem is to avoid test fixtures, and design test cases working with all sets of data. This might work for testing some simple logic. But it does not work or will involve significant efforts to create test cases for complex logic, e.g., an inventory handling with different unit of measurements, which requires significant programming of complex test logic to create data irrelevant test cases.

Another approach is to isolate data persistence by creating mock objects. This could be achieved by implementing interfaces over the data persistence layer or business logic layer, and creating and returning mock objects without touching underlying mobile infrastructure data persistence. The disadvantages of this approach include that: it needs significant programming of application specific mock objects to simulate test fixtures, it is not general across applications, data generating logics are not separated from test cases, and test environment is very different from real environment, etc.

A further approach is to set up data fixtures at the server side and then download them to the client side. However, the complexity and huge data/customizing dependencies on the server side make it difficult to set up and reproduce fixed data set for client unit test purpose. In addition, in the case of server change or migration, test cases may be broken.

However, one problem for setting up test fixtures from the client side is the authority to create data from the client side. Mobile infrastructure contains a data persistence and synchronization framework to synchronize data between a client and a server. The data persistence and synchronization framework has a data meta definition to define the table and field structure on the client side. In order to prevent unintended operations by application programs, the data meta definition can restrict the authority to create, modify or delete data in data tables from the client side. For example, data in the material master table is not allowed to be created from the client side. This authority restriction, although a good design practice, makes it impossible for a test automation program to create test data freely using normal program interfaces provided by mobile infrastructure.

Further, data exchange messages between the server and the client are in XML format, which contains information like table name, actions, record ID, data record field values, etc. However, it is difficult to maintain data in the XML format. For example, it would be difficult, without spending large efforts on developing a proprietary tool, to perform the following common maintenance tasks on data in the XML format:

1) To have an overview list of all records, sorted by certain fields.

2) To apply changes to the same field of all records, e.g., applying a fixed value, or incremental values.

3) When an application program is upgraded, data model may need to be enhanced, e.g., additional fields are required to be added to a table for new functions. In such a data model enhancement during application migration, it would cost significant efforts to maintain test data in XML format.

The mobile infrastructure test layer is a unit test layer for testing mobile infrastructure, not for testing applications based on mobile infrastructure. Its test focus is network functionality and protocol correctness, instead of correctness of application logic. Test data is maintained in raw messages in XML format, and significant efforts are required for data maintenance. Additionally, there is no data capture concept or end-to-end integrated build process concept in the mobile infrastructure test layer.

Thus, it would be desirable to provide a test automation method which is applicable to mobile infrastructure based applications, and all other software programs as well.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 illustrates an architecture of a test automation method according to an embodiment of the present invention.

FIG. 2 illustrates a data flowchart of a test automation method according to an embodiment of the present invention.

FIG. 3A illustrates a flowchart of a test automation method according to an embodiment of the present invention, and FIG. 3B illustrates a screenshot a root test according to one embodiment present invention.

FIG. 4 illustrates an exemplary class relationship among JUnit classes used to create test cases.

FIG. 5 illustrates an exemplary organization of test cases according to an embodiment of the present application.

DETAILED DESCRIPTION OF EMBODIMENTS

Embodiments of the present invention provide a method and system to create test data by simulating data exchange messages between the server and the client and stores test data in Comma Separated Value (CSV) files. In further embodiments, data repository files stored in the CSV format can be edited by common tools, for example, a spreadsheet program, and can be maintained easily. In addition, the CSV format itself is suitable for migration. A good migration of data model design is backward compatible, which means keeping existing fields unchanged and appending new fields if any, so that test cases created in lower versions of an application program can be used in higher versions of the application program. In further embodiments, the present invention provides a test automation method. The test automation method and system provides a data capturer tool so that data repository may be created based on any existing test environment. The test automation method also converts data repository files and simulates messages in order to load data to a mobile infrastructure system and set up data fixtures. The test automation method further provides a build process so that data repository and test cases may be validated against any program changes periodically.

FIG. 1 illustrates an architecture of a test automation method according to an embodiment of the present invention. In this embodiment, the test automation method is used for unit testing of the client side of mobile infrastructure based applications. For example, Mobile Direct Store Delivery (DSD) 2.0 SR2 from SAP™. The test automation method of the present invention is applicable to all types of software programs.

A test data capturer at 101 could record data of an existing application environment at 102, for example, a downloaded development data image, or a bug report data image. The test data capturer reads application data 1022 of the existing application environment through APIs of a mobile infrastructure MI 1021, and exports data in CSV files to a test data repository at 103. It should be understood that other data format which could be easily maintained could also be used. An application 1023 could request for the application data 1022 through the mobile infrastructure MI 1021 too.

The test data capturer of the present invention is application independent. In a further embodiment, the test data capturer can be delivered as an add-on to the mobile infrastructure. Once applied, the test data capturer can help capture application test environment by accessing mobile infrastructure menus.

Data in the test data repository can later be used by a test automation framework at box 108 for testing. In a further embodiment, the data is used in periodical build process.

Test data is stored in CSV files in the test data repository at 103. A test environment is represented by a set of CSV files, each of which represents one Synchronize Business Object (SyncBO) or a child table of a SyncBO. SyncBO is a concept in mobile infrastructure, and is used to synchronize data between a server an a client. For example, in a test environment, DSD_DELIV represents a delivery SyncBO, 010 is its child table for delivery items, and totally two CSV files are needed.

Data in the test data repository can be maintained by a test data editor at 104. The CSV format is useful for test automation because it can be maintained easily as a table sheet by commercially available tools, such as Excel™ from Microsof™, Lotus 1-2-3™ from IBM™. Data in CSV format can also be displayed in a grid table, sorted by different fields, etc. In further embodiments, changes can be applied to same column of different records.

A test data CSV file stored in the test data repository according to one embodiment of the present invention is shown in Table 1. As shown, a simplified set of sample material test data is sorted by MAT_NO field. The CSV file, or the SyncBO, has five fields: PARENT_KEY, SYNC_KEY, MAT_NO, MAT_DESC1, and MAT_TYPE.

TABLE 1 PARENT_KEY SYNC_KEY MAT_NO MAT_DESC1 MAT_TYPE 4825971 CP_10099 BIER 1 * 20 L PPAS(BATCHMAT) FERT 4825980 CP_10100 BIER 1 * 20 L FERT 4825989 CP_10101 BEER BLOND KEG 1 * 20.00 L FERT 4825996 CP_10102 CHICKEN BREAST 3 FERT 4826005 CP_10103 BEER LIGHT KEG 1 * 20.00 L FERT 4826013 CP_10104 CHICKEN BREAST FERT

As shown in Table 1, the SyncBO has six records. The SYNC_KEY field needs to be unique for each record in the test data repository. This can be achieved by defining a SYNC_KEY number range for each SyncBO or implementing special logic to regenerate SYNC_KEY in the test framework.

Not all fields of a table (SyncBO or child table of a SyncBO) need to be maintained in a test data CSV file. The order of the fields is not important either, except that the PARENT_KEY field, which is used to link a top SyncBO and its child items in another table, should always be in the first column of a table. The PARENT_KEY field contains the SYNC_KEY field value of the parent record to be linked. For a top record which has no parent, this field should be left empty. Thus, a test data CVS file can maintain only a subset of columns of a table (SyncBO or child table of a SyncBO), which are relevant for test cases.

In the case of a data model enhancement in application version migration, the present invention allows additional fields to be added to tables easily, thus enabling test data and test cases in old versions of an application program to work with new versions of the application program without changes. The compatibility can reduce the cost of maintaining test data and test cases in application migration.

In addition, a user can add comments to any columns which do not belong to a SyncBO, for example, by adding marks to the last column of a record indicating that the record's special values are being used by a test case and should not be changed, as shown in Table 2 below.

TABLE 2 PARENT_KEY SYNC_KEY TOUR_ID CHECK_ID ITM_NO INV_TYPE 4852341 4852342 S0000005146 1 10 1 4852341 4852343 S0000005146 1 20 1 4852341 4852344 S0000005146 1 30 1 4852341 4852345 S0000005146 1 40 1 4852341 4852346 S0000005146 1 50 1 4852341 4852347 S0000005146 1 60 1 4852341 4852348 S0000005146 1 70 1 4852341 4852349 S0000005146 1 80 1 4852341 4852350 S0000005146 1 90 1 4852341 4852351 S0000005146 1 100 1 4852341 4852352 S0000005146 1 110 1 4852341 4852353 S0000005146 1 120 1 4852341 4852354 S0000005146 1 130 1 4852341 4852355 S0000005146 1 140 1 4852341 4852356 S0000005146 1 150 1 ROTRU PARENT_KEY MAT_NO UOM CK PLAN_QTY ACT_QTY 4852341 MDSD_00001 ST 3 3 Com- 4852341 MDSD_00002 ST 3 3 ments 4852341 MDSD_00003 ST 3 3 Do not 4852341 MDSD_00004 ST 3 3 change. 4852341 MDSD_00005 ST 3 3 4852341 MDSD_00006 ST 3 3 4852341 MDSD_00007 ST 3 3 4852341 MDSD_00008 ST 3 3 4852341 MDSD_00009 ST 3 3 4852341 MDSD_00010 ST 3 3 4852341 MDSD_00011 ST 3 3 4852341 MDSD_00012 ST 3 3 4852341 MDSD_00013 ST 3 3 4852341 MDSD_00014 ST 3 3 4852341 MDSD_00015 ST 3 3

A test automation framework at 106 utilizes JUnit at 107 as base framework to facilitate test case and test suite management. The test automation framework accesses a mobile infrastructure 108 through a mobile Infrastructure (MI) test layer 1081. The test automation framework reads CSV files from the test data repository at 103, and generates simulation messages at 105. The simulation messages are sent to the MI test layer 1081 to trigger message processing with the mobile infrastructure 108.

The test automation framework 106 could have logic to support test data maintained in a subset of columns of a table. This increases test data and test case compatibility in the case of test data model migration and reduces maintenance cost.

Different from the existing application environment at 102 used for data preparation, the mobile infrastructure at 108 represents the currently running environment.

In an embodiment, the mobile infrastructure 108 further has a user interface simulator, so that a user can not only automate test with the data repository, but also debug using the underlying data repository like a usual mobile infrastructure application with user interfaces.

Persistence data at 109 represents data stored on a mobile device by the mobile infrastructure 108, and could be accessed by the mobile infrastructure.

Test cases 110 are created for each to-be-tested application 111, utilizing the JUnit at 107, the test automation framework at 106, and the to-be-tested application at 111. In one embodiment, the test cases are JAVA™ files.

FIG. 2 shows a data flowchart of a test automation method according to an embodiment of the present invention.

The data flow chart in FIG. 2 covers both the data capture phase and the automated test phase of the present invention. In the data capture phase, at 201, MI data stored in a MI data store at 220 in SyncBO and row format is retrieved. At 202, the captured data in record and field format is stored in a test data repository at 230 in CSV format.

In the automated test phase, at 211, test data in CSV format from the test data repository at 230 is parsed. At 212, dummy message IDs and state IDs are generated. At 213, simulation messages are created from parsed data in record and field format and the generated IDs in order to simulate data exchange messages between a mobile device and mobile infrastructure. At 214, simulation messages sent to the mobile infrastructure trigger the processing of the mobile infrastructure to generate test data, which is in SyncBO and row format and is sent to the MI data store at 220.

At 215, the application to be tested retrieves the test data from the MI data store 220 in SyncBO and row format and performs test application logic according to requirements defined in test cases from 240. At 216, actual results from 215 and expected results from 240 are compared and the resulting test results are stored in 250.

FIG. 3A shows a flow chart of a test automation method according to one embodiment of the present invention. In this embodiment, the test automation method is integrated in a daily build process, and data repository and test cases are validated against any program changes every day. The test automation method of the present invention could be integrated in other build processes which trigger tests regularly.

Box 310 is for new features to be tested. The specification and design are created at 311, and test data are prepared at 312. If the existing test data repository is not enough to test new features, at 312, the test data repository is expanded or a complete new test data repository is created by either manually maintaining test data in grid tables or capturing necessary new test data. As discussed above, test data in the present invention is stored in CSV files in the test data repository and could be maintained easily.

At 313, test cases are created based on the specification, design and test data, so that the correctness of implementations can be verified. Then new features are developed at box until they pass all test cases.

Box 320 is for fixing bugs. When a bug is reported, either from a customer or an internal tester, at 321, the problem is reproduced either on a set of development data or a data image sent by the reporter. The test data set is captured at 322. The reproduced test data set can either be merged into an existing test data repository by adding fields to end of CSV files, or be used to create a new test data repository. At 323, test cases are created based on the test data and the expected correct behavior so that a correction of the bug can be verified. At 324, a bug fix is developed until it passes all test cases.

Once a new feature or a bug fix is completed and locally tested with predefined test cases, the test data repository in CSV files, test cases and source code of the development for the new feature or the bug fix can be checked into a centralized version management tool, at 330.

In an embodiment, the test automation method of the present invention is integrated in a night build process. The night build process is triggered every night and automatically synchronizes, at step 341, all checked-in up-to-date files from the version management tool to a build server. As described above, the checked-in up-to-date files from the version management tool at 330 include test data repository, test cases and application source code.

In an embodiment, application source code and test cases are compiled to binary format at 342 and 343. A temporary runtime test environment could be built on the build server 340 at 344. Test cases are executed at 345. Any newly checked in changes are verified with these test cases.

If any of the automated tests is failed, the night build process will be stopped and a notification email will be sent to the registered mail list so that development team will know this test failure. A detailed test result will also be available on the build server for diagnosing purposes.

An example of using the method of the present invention to test a DSD application is described below. It should be understood that the method and system of the present invention could be easily applied to other applications.

1. Setting Up the Environment.

TABLE 3 JAVA ™ JAVA ™Source Codes +com.sap.ip.me Workaround MI source code for MI 2.5 SP13 +com.sap.mbs.test General test tools across applications +data Message simulation, data capturer, etc. data related tools +setup General test setup classes +util Utility classes +com.sap. test Application specific test tools and test entry classes: Main, Debug, etc +setup Application specific setup classes +(component) Component specific test cases setup Data setup related files +app Application level meta and configuration, etc. +data Data repositories

In embodiments of the present invention, a test project for an application to be tested, e.g., DSD, is set up in an eclipse (or import application jar file) first. Libraries shown in Table 4 are used for setting up the test project:

TABLE 4 Library Name Version Where to Get ME.jar MI 2.5 SP13 Perforce lib folder db2ejdbc.jar 8.2 Perforce lib folder MITest.jar After MI 2.5 SP13 Perforce lib folder crimson.jar Shipped with MI 2.5 SP13 Perforce lib folder jaxp.jar Shipped with MI 2.5 SP13 Perforce lib folder xalan.jar Shipped with MI 2.5 SP13 Perforce lib folder junit.jar 3.7 for JDK 1.3 Perforce lib folder (3.7) 3.8.1 for JDK 1.4 http://www.junit.org/

Setting up steps for the eclipse include:

-   -   synchronizing to head version of source code in a perforce_test         folder;     -   creating a new project in the eclipse, wherein the project home         is_test folder;     -   adding “JAVA”™ and “setup” folders to source;     -   importing all library files mentioned above; and     -   linking the project or add an application jar file.

Then the root test (which contains all other tests) is run by program junit.awatui.TestRunner with the test class name as parameter, as shown in FIG. 3B.

Next, a JUnit 3.7 jar file is copied to ant/lib folder to setup an ant.

To run from the ant, an application jar file (e.g., go to_core/cfg folder, ant makeJar) is built, and test cases are built. The test then begins. Ant will provide an overview report on the total number of tests run, number of failures, etc. A more detailed report could be saved as TEST-testclassname.txt file.

2. Prepare Test Data

As discussed above, data repository files in the present invention are in CSV format and Excel could be used to edit the test data. However, Excel will automatically format every cell to “general” format not “text” format for CSV files and this will cause missing of leading zeros. To avoid the leading zero issue of Excel, file suffixes could be changed to “csv1”.

A user can use OpenCSVMacro.xls to open and save data repository files to avoid leading zero issues. The procedure could be:

-   -   open OpenCSVMacro.xls files, and select “enable Macros”;     -   to open a data repository file, run macro “OpenMacro” or press         CTRL-o;     -   to save a data repository file, run macro “SaveMacro” or press         CTRL-s;     -   check that the file saved is in appropriate CSV format.

Test data could also be prepared by capturing data from an existing environment. The procedure could be:

-   -   deploy MBSTest.zip as an add-on to a device, or manually add         MBSTest.zip to lib folder and listOfJar.txt file;     -   after data capture add-on is deployed, data can be captured by         clicking OK on the About Dialog of mobile infrastructure any         time after the application is started;     -   a timestamp folder will be created under the root folder and         data repository files are generated under that folder.

3. Create Test Cases

JUnit could be used to manage test cases and test suites in the test automation method of the present invention. FIG. 4 shows a example of class relationship among JUnit classes used to create test cases. For the sake of brevity, only classes relevant to the test automation method of the present invention are shown, with classes for implementation details omitted.

JUnit classes Test 401, TestSuite 402, TestCase 403, TestDecorator 404 and TestSetup 405 use composite and decorator design patterns, which make it possible to create very flexible structure of test cases and sets of test cases and to apply setup fixtures for test cases and sets of test cases. In these JUnit classes, the Testsuit class 402 is composed of many Tests, which can be TestCases or even TestSuites; and the TestSetup class 405 can decorate a Test, which can be a TestCase, a TestSuite or another TestSetup.

A MetaSetup class 406 loads data model meta, such as definition of database or SyncBO. A DataRepositorySetup class 407 loads a data repository. An application setup 408 is used to initialize and activate application. The procedure runs the MetaSetup class 406, the DataRepositorySetup class 407 and the application setup 408, and then runs the Testsetup 405 before each test.

FIG. 5 shows an exemplary organization of test cases according to an embodiment of the present application. The test case structure may be very flexible, because composite and decorator patterns are used.

The execution sequence of the test cases shown in FIG. 5 is as follows:

-   -   MataSetup.setUp( )     -   DataRepository1Setup.setUp( )     -   ApplicationSetup.setUp( )     -   TestCase111.setUp( )     -   TestCase111.test . . . ( )     -   TestCase111.test . . . ( )     -   . . .     -   TestCase111.tearDown( )     -   TestCase112 . . .     -   . . .     -   DataRepository1Setup.tearDown( )     -   DataRepository2Setup . . .     -   . . .     -   MetaSetup.tearDown( )

While the invention has been described in detail above with reference to some embodiments, variations within the scope and spirit of the invention will be apparent to those of ordinary skill in the art. For example, although embodiments are described with reference to a computer, other electrical device could be used. 

1. A computer implemented method for testing a mobile infrastructure based software program, comprising: obtaining data representing a pre-existing application environment, the data being in a first format; performing test logic for the software program with the obtained data according to at least one requirement defined in at least one test case; comparing results from performing the test logic with expected results; storing results of the comparison; storing the data of the first format in a test data repository in a second format; converting data from the test data repository from the second format to the first format; creating simulation messages with the converted data to simulate data exchange messages between a mobile device and mobile infrastructure; sending the simulation messages to the mobile infrastructure; and triggering processing of the mobile infrastructure by the simulation messages to generate test data in the first format; wherein the first format is a record and field format.
 2. The method of claim 1, wherein the second format is Comma Separated Value (CSV) format.
 3. The method of claim 1, further comprising editing data in the test data repository with a spreadsheet program.
 4. The method of claim 1, further comprising sending the created test data to a data store.
 5. The method of claim 1, wherein the data representing the pre-existing application environment is from a mobile infrastructure data store.
 6. The method of claim 1, wherein the data representing the pre-existing application environment is captured by an add-on delivered to the mobile infrastructure.
 7. The method of claim 1, further comprising checking the software program, the test data repository and the at least one test case into a version management tool on a regular basis.
 8. The method of claim 7, wherein the software program, the test data repository and the at least one test case are checked into the version management tool daily.
 9. The method of claim 7, wherein the software program is for a new feature.
 10. The method of claim 7, wherein the software program is used to fix a bug.
 11. The method of claim 7, further comprising synchronizing newly checked in source code of the software program to the source code of the software program in the version management tool.
 12. The method of claim 7, further comprising testing an up-to-date software program with an up-to-date test data repository and an up-to-date test case.
 13. The method of claim 1, wherein the first format is Synchronize Business Object and row format.
 14. A system for testing a mobile infrastructure based software program, comprising: a test data capturer, stored in a computer, for capturing data representing a pre-existing application environment in a first format and exporting the captured data in a second format; a test data repository for storing in a computer test data from the test data capturer in the second format; and a test automation controller for creating a simulation message to simulate a data exchange message between a mobile device and the mobile infrastructure, to transmit the simulation message to the mobile infrastructure and to trigger processing of the mobile infrastructure to generate the test data in the first format representing the pre-existing application environment; wherein the first format is a record and field format.
 15. The system of claim 14, further comprising a test data editor, wherein the test data editor is a non-proprietary tool.
 16. The system of claim 14, wherein the second format is Comma Separated Value (CSV) format.
 17. The system of claim 14, wherein the test automation controller accesses data stored in the test data repository.
 18. The system of claim 14, further comprising a test case generator which communicates with the test automation controller and generates a test case for the software program.
 19. A computer implemented method for testing a mobile infrastructure based software program, comprising: creating a simulation message to simulate a data exchange message between a mobile device and the mobile infrastructure; sending the simulation to the mobile infrastructure; triggering processing of the mobile infrastructure by the simulation message to generate test data representing a pre-existing application environment, the data being in a first format; storing the data in a second format; converting the stored data to the first format; and testing the software program with the converted data to create real time running test data; wherein the first format is a record and field format. 